home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2005 October
/
PCWOCT05.iso
/
Software
/
FromTheMag
/
Syn Text Editor 2.1.0.46
/
synsetup-2.1.0.46.exe
/
{app}
/
scripts
/
exportpdf.vbs
< prev
next >
Wrap
Text File
|
2003-08-13
|
8KB
|
248 lines
' Caption: Export to PDF...|
' Hint: Export to PDF file using HTMLDOC|
' Icon: expdf.ico|
'
' syn
' Copyright (C) 2000-2003, Ascher Stefan. All rights reserved.
' stievie@utanet.at, http://web.utanet.at/ascherst/
'
' The contents of this file are subject to the Mozilla Public License
' Version 1.1 (the "License"); you may not use this file except in compliance
' with the License. You may obtain a copy of the License at
' http://www.mozilla.org/MPL/
'
' Software distributed under the License is distributed on an "AS IS" basis,
' WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
' the specific language governing rights and limitations under the License.
'
' The Original Code is exportpdf.vbs, released Sun, 26 May 2002 10:55:39 UTC.
'
' The Initial Developer of the Original Code is Ascher Stefan.
' Portions created by Ascher Stefan are Copyright (C) 2000-2003 Ascher Stefan.
' All Rights Reserved.
'
' Contributor(s): .
'
' Alternatively, the contents of this file may be used under the terms of the
' GNU General Public License Version 2 or later (the "GPL"), in which case
' the provisions of the GPL are applicable instead of those above.
' If you wish to allow use of your version of this file only under the terms
' of the GPL and not to allow others to use your version of this file
' under the MPL, indicate your decision by deleting the provisions above and
' replace them with the notice and other provisions required by the GPL.
' If you do not delete the provisions above, a recipient may use your version
' of this file under either the MPL or the GPL.
'
' You may retrieve the latest version of this file at the syn home page,
' located at http://syn.sourceforge.net/
'
' $Id: exportpdf.vbs,v 1.3.2.5 2003/08/13 00:38:45 neum Exp $
' This Script Exports the active file with Syntaxhighlight to a PDF file using
' HTMLDOC, you can get it for free from http://www.easysw.com/htmldoc/. You can
' customize the appearance with modifing the commandline options, see the HTMLDOC
' Manual.
' You need the commandline version from HTMLDOC, but there is no precompiled
' distribution available. You may want to download the source code, and compile
' it yourself, or you can use an older version.
'HTMLDOC Version 1.8.19 Copyright 1997-2002 Easy Software Products, All Rights Reserved.
'This software is governed by the GNU General Public License, Version 2, and
'is based in part on the work of the Independent JPEG Group.
'
'Usage:
' htmldoc [options] filename1.html [ ... filenameN.html ]
'
'Options:
'
' --batch filename.book
' --bodycolor color
' --bodyfont {courier,times,helvetica}
' --bodyimage filename.{gif,jpg,png}
' --book
' --bottom margin{in,cm,mm}
' --browserwidth pixels
' --charset {8859-1...8859-15}
' --color
' --compression[=level]
' --datadir directory
' --duplex
' --effectduration {0.1..10.0}
' --encryption
' --firstpage {p1,toc,c1}
' --fontsize {6.0..24.0}
' --fontspacing {1.0..3.0}
' --footer fff
' {--format, -t} {ps1,ps2,ps3,pdf11,pdf12,pdf13,pdf14,html}
' --gray
' --header fff
' --headfootfont {courier{-bold,-oblique,-boldoblique},
' times{-roman,-bold,-italic,-bolditalic},
' helvetica{-bold,-oblique,-boldoblique}}
' --headfootsize {6.0..24.0}
' --headingfont {courier,times,helvetica}
' --help
' --jpeg[=quality]
' --landscape
' --left margin{in,cm,mm}
' --linkcolor color
' --links
' --linkstyle {plain,underline}
' --logoimage filename.{gif,jpg,png}
' --owner-password password
' --no-compression
' --no-duplex
' --no-encryption
' --no-links
' --no-localfiles
' --no-numbered
' --no-pscommands
' --no-title
' --no-toc
' --no-truetype
' --numbered
' {--outdir, -d} dirname
' {--outfile, -f} filename.{ps,pdf,html}
' --pageduration {1.0..60.0}
' --pageeffect {none,bi,bo,d,gd,gdr,gr,hb,hsi,hso,vb,vsi,vso,wd,wl,wr,wu}
' --pagelayout {single,one,twoleft,tworight}
' --pagemode {document,outline,fullscreen}
' --path "dir1;dir2;dir3;...;dirN"
' --permissions {all,annotate,copy,modify,print,no-annotate,no-copy,no-modify,no-print,none}
' --portrait
' --proxy http://host:port
' --pscommands
' --quiet
' --right margin{in,cm,mm}
' --size {letter,a4,WxH{in,cm,mm},etc}
' --textcolor color
' --textfont {courier,times,helvetica}
' --title
' --titlefile filename.{htm,html,shtml}
' --titleimage filename.{gif,jpg,png}
' --tocfooter fff
' --tocheader fff
' --toclevels levels
' --toctitle string
' --top margin{in,cm,mm}
' --truetype
' --user-password password
' {--verbose, -v}
' --version
' --webpage
'
' fff = heading format string; each 'f' can be one of:
'
' . = blank
' / = n/N arabic page numbers (1/3, 2/3, 3/3)
' : = c/C arabic chapter page numbers (1/2, 2/2, 1/4, 2/4, ...)
' 1 = arabic numbers (1, 2, 3, ...)
' a = lowercase letters
' A = uppercase letters
' c = current chapter heading
' C = current chapter page number (arabic)
' d = current date
' D = current date and time
' h = current heading
' i = lowercase roman numerals
' I = uppercase roman numerals
' l = logo image
' t = title text
' T = current time
option explicit
'#include <cmnfunc>
'#include <consts>
' You should modify the Path to HTMLDOC
'const htmldoc = "D:\Eigene Dateien\C Projects\htmldoc\visualc\htmldoc.exe"
const htmldoc = "D:\Programme\htmldoc\htmldoc.exe"
sub Main(dummy)
if Documents.Count = 0 then
MsgBox "No Document open.", vbCritical
exit sub
end if
dim pdffile, htmfile
with Create("TSaveDialog", Self)
.Filter = "PDF Files (*.pdf)|*.pdf|All Files (*.*)|*.*"
.DefaultExt = "pdf"
.Options = .Options & ",ofOverwritePrompt"
.InitialDir = ExtractFilePath(ActiveDocument.FileName)
.FileName = ChangeFileExt(ActiveDocument.FileName, ".pdf")
.Title = "Export to PDF"
if .Execute then
Cursor = crHourGlass
pdffile = .FileName
htmfile = TempFile
if ActiveDocument.TypeName = "Text" then
' Export does not work with plain text files
StringToFile "<pre>" & ActiveDocument.Text & "</pre>", htmfile
else
ActiveDocument.Export etHTML, false, htmfile
end if
if FileExists(htmfile) then
Execute AddQuotesUnless(htmldoc) & " -t pdf13 --webpage --size a4 --pagelayout single " & _
AddQuotesUnless(htmfile) & " -f " & AddQuotesUnless(pdffile), 0, true
DeleteFile(htmfile)
else
MsgBox "Something went wrong while exporting the file.", vbCritical
end if
Cursor = crDefault
end if
.Free
end with
end sub
' If you want to export all currently open files uncomment the lines bellow, and
' delete the Sub Main above
'sub Main()
' if Documents.Count = 0 then
' MsgBox "No Document open.", vbCritical
' exit sub
' end if
' dim dlg
' dim pdffile, htmfile
'
' dlg = Create("TSaveDialog", Self)
' with dlg
' .Filter = "PDF Files (*.pdf)|*.pdf|All Files (*.*)|*.*"
' .DefaultExt = "pdf"
' .Options = .Options & ",ofOverwritePrompt"
' .Title = "Export to PDF"
' end with
' dim i
' dim doc
' for i = 0 to Documents.Count - 1
' set doc = Documents(i)
' with dlg
' .InitialDir = RemoveFileName(doc.FileName)
' .FileName = ChangeFileExt(doc.FileName, ".pdf")
' if .Execute then
' Cursor = crHourGlass
' pdffile = .FileName
' htmfile = ChangeFileExt(pdffile, ".html")
' if doc.TypeName = "Text" then
' ' Export does not work with plain text files
' StringToFile "<pre>" & doc.Text & "</pre>", htmfile
' else
' doc.Export etHTML, false, htmfile
' end if
' if FileExists(htmfile) then
' Execute AddQuotesUnless(htmldoc) & " -t pdf13 --webpage --size a4 --pagelayout single " & _
' AddQuotesUnless(htmfile) & " -f " & AddQuotesUnless(pdffile), 0, true
' else
' MsgBox "Something went wrong while exporting the file.", vbCritical
' end if
' DeleteFile(htmfile)
' Cursor = crDefault
' end if
' end with
' next
' dlg.Free
'end sub